class Solution(object):
    def maxIceCream(self, costs, coins):
        costs.sort()
        now = 0
        n = len(costs)
        index = 0
        while index < n:
            now += costs[index]
            if now <= coins:
                index += 1
            else:
                break
        return index